package Collection1;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

public class Sort1 {
    public static void main(String[] args) {
        ArrayList<Integer>integers=new ArrayList<>();
        integers.add(23);
        integers.add(32);
        integers.add(11);
        integers.add(54);
        integers.add(13);
        integers.add(79);
        integers.add(47);
        System.out.println("integers = " + integers);
        Collections.sort(integers);
        System.out.println("integers = " + integers);
        System.out.println("------------------------------");
        System.out.println("自定义排序");
        Collections.sort(integers, new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
//                return o2-o1;
                return o1-o2;
            }
        });
        System.out.println("integers = " + integers);

    }
}
